#pragma once

using namespace std;

class t_MessageQueue
{ 
	list<t_Message> p_MessageList;
	HANDLE threadHandle;
	CRITICAL_SECTION CriticalSection; //!< Critical section for modifying message queue

public:
	int Poll(void); //!< Go though message list and deliver messages to their recipients 
	int StartThread(void); //!< Start separate thread for automatic message delivery 
	int StopThread(void); 
	static DWORD WINAPI ThreadEntry(void *pArg);
	int Insert(const t_Message& );
	int SendMessage(t_MessageRecipient* p_MessageRecipient, int type, int msg, clock_t time);
	t_MessageQueue(void);
	~t_MessageQueue(void);
};

